#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int table[101];
	for(int i = 1; i <= n; i++)
		cin >> table[i];
	int sum = 0;
	for(int i = 1; i <= n; i++)
		sum += table[i];
	int idel = sum / n;
	int result = 0;
	for(int i = 1; i < n; i++){
		int change = idel - table[i];
		if(change == 0) continue;
		table[i] += change;
		table[i + 1] -= change;
		result++;
	}
	cout << result << endl;
}
